/*
 * @Author: your name
 * @Date: 2021-06-17 09:29:42
 * @LastEditTime: 2021-06-18 17:02:32
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \bazai_ebook\src\utils\create-api.js
 */

import CreateAPI from 'vue-create-api'
import Vue from 'vue'
import Toast from '@/components/common/Toast'
import Popup from '@/components/common/Popup'
import GroupDialog from '@/components/shelf/ShelfGroupDialog'

Vue.use(CreateAPI)
Vue.createAPI(Toast, true)
Vue.createAPI(Popup, true)
Vue.createAPI(GroupDialog, true)

Vue.mixin({
  methods: {
    toast (settings) {
      return this.$createToast({
          $props: settings
      })
    },
    popup (settings) {
      return this.$createPopup({
          $props: settings
      })
    },
    simpleToast(text) {
      const toast = this.toast({
        text: text
      })
      toast.show()
      toast.updateText(text)
    },
    dialog(settings) {
      return this.$createGroupDialog({
        $props: settings
      })
    }
  }
})
